import 'package:flutter/material.dart';

class DashedLine extends StatelessWidget {
  DashedLine({
    @required this.axis,
    this.dashedWidth = 1,
    this.dashedHeight = 1,
    this.count,
    this.color = const Color(0xffaaaaaa),
  });

  final Axis axis;
  final double dashedWidth;
  final double dashedHeight;
  final int count;
  final Color color;

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(builder: (context, contraints) {
      // 根据宽度计算个数
      return Flex(
        direction: this.axis,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: List.generate(this.count, (index) {
          return SizedBox(
            width: dashedWidth,
            height: dashedHeight,
            child: DecoratedBox(
              decoration: BoxDecoration(color: color),
            ),
          );
        }),
      );
    });
  }
}
